home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 2.9 KB | 92 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: SLSrtArr.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef SLSRTARR_H
- #define SLSRTARR_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- struct FW_SPrivSortedArray;
- typedef FW_SPrivSortedArray* FW_HSortedArray;
-
- //========================================================================================
- // Typedefs
- //========================================================================================
-
- typedef int (*FW_SortedArray_CompareFunction)(void* first, void* second);
- // return negative integer if first is less than second
- // return 0 if first == second
- // return positive integer if first is greater than second
-
- //========================================================================================
- // Extern C Methods
- //========================================================================================
-
- FW_EXTERN_C_BEGIN
-
- #if defined(FW_ODFLIB_IMPORT)
- #pragma import on
- #elif defined(FW_ODFLIB)
- #pragma export on
- #endif
-
- FW_HSortedArray FW_PrivSortedArray_New(FW_PlatformError* error,
- FW_SortedArray_CompareFunction compare);
-
- void FW_PrivSortedArray_Dispose(FW_HSortedArray self);
-
- long FW_PrivSortedArray_GetLength(FW_HSortedArray self);
- // Retrieve the number of items
-
- void* FW_PrivSortedArray_GetItemAt(FW_HSortedArray self, long index);
- // Retrieve the item at location index
-
- FW_Boolean FW_PrivSortedArray_Find(FW_HSortedArray self,
- void* item,
- long* index);
- // Do a binary search for item
- // If item is found, function result is true and index is the location of the item
- // If item is not found, result is false, and index is location where item
- // would be inserted
-
- void FW_PrivSortedArray_Insert(FW_HSortedArray self,
- void* newItem,
- long index,
- FW_PlatformError* error);
- // Item is inserted into the array at location index.
- // It is client's responsiblity to insert item in a location
- // that preserves sorting. Use FW_PrivSortedArray_Find
- // to find the correct location
-
-
- void FW_PrivSortedArray_Add(FW_HSortedArray self,
- void* newItem,
- long* index,
- FW_PlatformError* error);
- // Item is inserted into the array in the location that preserves sorting.
- // The location is returned in *index.
- // Items must be unique, so it is an error if there already exists an item
- // in the array which when compared to newItem returns kEqual
-
- #if defined(FW_ODFLIB_IMPORT)
- #pragma import off
- #elif defined(FW_ODFLIB)
- #pragma export off
- #endif
-
- FW_EXTERN_C_END
-
- #endif
-